package com.wanghua.mall.search.controller;

import com.wanghua.common.dto.es.SkuEsModel;
import com.wanghua.common.exception.ExceptionCodeEnum;
import com.wanghua.common.utils.R;
import com.wanghua.mall.search.service.EsSaveService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 保存数据
 *
 * @author wanghua
 * @create 2021-08-27 10:39
 */
@RestController
@RequestMapping("/search/essave")
public class EsSaveController {

    @Resource
    private EsSaveService esSaveService;

    //上架商品
    @PostMapping("/productUp")
    public R productUp(@RequestBody List<SkuEsModel> skuEsModelList) {
        boolean b = esSaveService.productUp(skuEsModelList);
        return b ? R.ok() : R.error(ExceptionCodeEnum.PRODUCT_UP_EXCEPTION.getCode(), ExceptionCodeEnum.PRODUCT_UP_EXCEPTION.getMsg());
    }
}
